
package com.gamatechno.solodestinationnew;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.gamatechno.solodestinationnew.adapter.AdapterSelectLang;
import com.gamatechno.solodestinationnew.utils.Utils;

public class PilihBahasaActivity extends Activity implements OnItemClickListener {

    private String[] bahasa = {
            "Bahasa Indonesia",
            "English US"
    };

    private int[] icon = {
            R.drawable.img_ina,
            R.drawable.img_en
    };

    private ListView lvSelectLang;
    private AdapterSelectLang adapter;

    private Bundle data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pilih_bahasa);

        data = getIntent().getExtras();

        lvSelectLang = (ListView) findViewById(R.id.lv_select_lang);
        adapter = new AdapterSelectLang(this, icon, bahasa);
        lvSelectLang.setAdapter(adapter);
        lvSelectLang.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
        Utils.TRACE("PilihBahasaActivity", "onItemClick : " + pos);
        switch (pos) {
            case 0:
                Utils.setLocale(this, "id");
                break;
            case 1:
                Utils.setLocale(this, "en");
                break;
            default:
                break;
        }

        startActivity(new Intent(this, MainActivity.class));
        finish();
    }

    @Override
    public void onBackPressed() {
        // TODO Auto-generated method stub
        super.onBackPressed();
        if (data != null) {
            startActivity(new Intent(this, SettingActivity.class));
            finish();
        }
    }

}
